package com.bwie.controller;

import com.bwie.pojo.TbBrand;
import com.bwie.service.TbBrandService;
import com.bwie.utils.R;
import com.bwie.utils.Result;
import com.bwie.vo.PageInfoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

@RestController
@RequestMapping("/shop/index")
public class IndexController {

    @Autowired
    TbBrandService tbBrandService;

    /**
     * @description 品牌添加
     * @params [tbBrand]
     * @return com.bwie.utils.Result
     * @author 杰
     * @date 2025/5/23 16:01
     */

    @PostMapping("/addBrand")
    public Result addBrand(@RequestBody TbBrand tbBrand){

        return tbBrandService.addBrand(tbBrand);
    }


    /**
     * @description 分页获取品牌列表
     * @params [pageInfoVo]
     * @return com.bwie.utils.Result
     * @author 杰
     * @date 2025/5/23 16:02
     */
    @PostMapping("/getBrandList")
    public Result getBrandList(@RequestBody PageInfoVo pageInfoVo){

        return tbBrandService.getBrandList(pageInfoVo);
    }


    /**
     * @description 修改商品状态
     * @params [tbBrand]
     * @return com.bwie.utils.Result
     * @author 杰
     * @date 2025/5/23 18:28
     */
    @PostMapping("/updateBrandStatus")
    public Result updateBrandStatus(@RequestBody TbBrand tbBrand){

        return tbBrandService.updateBrandStatus(tbBrand);
    }

    /**
     * @description 品牌列表无分页
     * @params []
     * @return com.bwie.utils.Result
     * @author 杰
     * @date 2025/5/27 11:14
     */
    @PostMapping("/getBrandlistSelect")
    public Result getBrandlistSelect(){
        return tbBrandService.getBrandlistSelect();
    }


    @PostMapping("/getDateText")
    public Result getDateText(){

        LocalDateTime now = LocalDateTime.now();
        System.out.println(now);
        String toString = now.toString();
        System.out.println(toString);

        LocalDateTime localDateTime = now.plusMinutes(20);

        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy年MM月dd日 HH时mm分ss秒");

        String format = now.format(formatter);

        String format1 = localDateTime.format(formatter);
        System.out.println(format1+"111");
        return Result.ok().setData(format);

    }
}
